Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Ensure operations that are unsafe during instance initialization raise errors #834

Merged
merged 5 commits into from
Sep 18, 2023

Conversation

philippjfr
Copy link
Member

We are finding that some users do not correctly call super().__init__() at all or perform actions that are not safe before they call it. To guide more users to the correct behavior and avoid undefined/weird behavior this PR adds some validations and errors to certain methods on the .param namespace.

param/parameterized.py Outdated Show resolved Hide resolved
param/parameterized.py Outdated Show resolved Hide resolved
@maximlt
Copy link
Member

maximlt commented Sep 16, 2023

I quickly tried that and found a few places where we run __getitem__ before the class is initialized:

That suggests that it'd be worth it but would break too much code, it's likely we need to go through a deprecation period.

@maximlt maximlt merged commit 0ee6ed9 into main Sep 18, 2023
10 checks passed
@maximlt maximlt deleted the instance_initialization_errors branch September 18, 2023 22:31
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants